/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jule.clases.treeFiles;

import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;


/**
 *
 * @author Administrador
 */
public class templateTreeRenderer implements TreeCellRenderer {

    private DefaultTreeCellRenderer templateIconRenderer;
    private DefaultTreeCellRenderer directoryIconRenderer;
    private DefaultTreeCellRenderer directoryExpandedIconRenderer;
   

    public templateTreeRenderer() {
        templateIconRenderer = new DefaultTreeCellRenderer();
        templateIconRenderer.setLeafIcon(new ImageIcon(getClass().getResource("/images/page_white_code.png")));
        templateIconRenderer.setOpenIcon(new ImageIcon(getClass().getResource("/images/page_white_code.png")));
        templateIconRenderer.setClosedIcon(new ImageIcon(getClass().getResource("/images/page_white_code.png")));

        
        directoryIconRenderer = new DefaultTreeCellRenderer();
        directoryIconRenderer.setLeafIcon(new ImageIcon(getClass().getResource("/images/folder.png")));
        directoryIconRenderer.setOpenIcon(new ImageIcon(getClass().getResource("/images/folder.png")));
        directoryIconRenderer.setClosedIcon(new ImageIcon(getClass().getResource("/images/folder.png")));

       
         directoryExpandedIconRenderer = new DefaultTreeCellRenderer();
        directoryExpandedIconRenderer.setLeafIcon(new ImageIcon(getClass().getResource("/images/folder_database.png")));
        directoryExpandedIconRenderer.setOpenIcon(new ImageIcon(getClass().getResource("/images/folder_database.png")));
        directoryExpandedIconRenderer.setClosedIcon(new ImageIcon(getClass().getResource("/images/folder_database.png")));

        
    }

    // recordar devolver siempre algo...
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
 

   if (leaf)
   {
      return templateIconRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
   }
   else if (expanded)
   {
      return directoryExpandedIconRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
   }
   else
   {// icono de database
      return directoryIconRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
   }

 

    }
}
